#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QPushButton>
#include "movebutton.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    m_moveButton = new MoveButton(this);
    m_moveButton->setBuddy(ui->widget);
    connect(ui->pushButton, SIGNAL(clicked(bool)), m_moveButton, SLOT(setExtended(bool)));
    connect(m_moveButton, SIGNAL(extended(bool)), ui->pushButton, SLOT(setChecked(bool)));

    connect(ui->pushButton, &QPushButton::clicked, [&](){
        QString txt = ui->pushButton->isChecked() ? "缩回" : "展开";
        ui->pushButton->setText(txt);
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::show()
{
    QMainWindow::show();
    m_moveButton->setExtended(false);
    ui->pushButton->setChecked(false);
}



